package com.ali.framework.gateway.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: Smile
 * @Date: 2023/12/15/10:49
 * @Description:
 */
@Configuration
public class GateWayConfig {

    /**
     * 第二种路由配置
     * @param routeLocatorBuilder
     * @return
     */
    @Bean
    public RouteLocator routeLocator(RouteLocatorBuilder routeLocatorBuilder){
        RouteLocator routes = routeLocatorBuilder.routes()
                .route("test-id", r -> r.path("")
                        .uri("http://news.baidu.com/"))
                .build();
        return routes;
    }

}
